<?php
namespace app\huaban\controller;
use think\Db;
use think\Request;
use think\Controller;
use think\Session;
use think\Cookie;

class User extends Controller
{
    public function index()
    {
        $session = session::get();
        $data = Db::name('huaban_user')->where('name',$session['huaban_user_name'])->find();
        $uid = $session['huaban_user_id'];
        $res = Db::name('huaban_integral')->where('uid',$uid)->find();
        $integral = $res['integral'];
        return view('/user/userCenter',[
            'data'=>$data,
            'integral'=>$integral,
        ]);
    }

    // 注销用户
    public function zhuxiao()
    {

        Session::delete('huaban_user_name');
        return $this->success('注销成功');

    }


    public function updateIcon(Request $request)
    {
        $session = session::get();
        $data = input('post.');
        $result = Db::table('xy_huaban_user')->where(['name'=>$session['huaban_user_name']])->update($data);

        if ($result > 0) {
            return $this->success('安排上了');
        } else {
            return $this->error('添加失败');

        }
//        if($this->request->isPost()){
//            $file = request()->file('file');
////            var_dump($file);
//            $info = $file->move('./static/uploads');
//
//           if($info){
//               echo $info->getExtension().'<br>';
//               echo $info->getSaveName().'<br>';
//               echo $info->getFilename().'<br>';
//           }else{
//               echo $file->getError();
//           }
//
//        }else{
//            return $this->fetch('fileupload');
//        }

    }

    public function updateUser()
    {
        $id = Request::instance()->param();

        $data = Db::name('huaban_user')->where('id',$id['id'])->find();


        return view('/user/updateUser',[
            'data'=>$data,
        ]);
    }






}